<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.Statement" %>
<%@ page import="java.sql.DriverManager" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>

<body>

<%@ include file="isLogin.jsp"%>
<%--<jsp:include page="isLogin.jsp" />--%>

<%

    //配置字符编码集
    request.setCharacterEncoding("utf8");

    //读取jsp中的数据并封装
    String username = request.getParameter("username");
    String password = request.getParameter("password");


    //3+1
    Connection connection = null;
    Statement statement = null;

    //t_users(id, username, password) id自动增加，
    String sql = "insert into t_users(username,password) " +
            "values('"+username+"','"+password+"')";

    Class.forName("com.mysql.jdbc.Driver");

    connection = DriverManager.getConnection(
            "jdbc:mysql://localhost:3306/sctu_javaweb_2018?serverTimezone=UTC",
            "root",
            "123456");
    statement = connection.createStatement();

    statement.execute(sql);

    statement.close();
    connection.close();
%>

<%--<%@ include file="footer.jsp" %>--%>

插入成功！！！

<jsp:include page="footer.jsp">
    <jsp:param name="year" value="2015" />
</jsp:include>

</body>
</html>